#include "WFloat.hpp"
#include <iostream>
using namespace std;

void average()
{
    cout << "Enter the number of values to average: ";
    int n;
    cin >> n;
    WFloat sum = 0;
    for (int i = 0; i < n; i++)
    {
        WFloat x;
        cin >> x;
        sum += x;
    }
    cout << "The average is \n"
         << sum / n << endl;
}

void TypeConversion(const WFloat &num)
{
    cout << "num              = " << num << endl;
    cout << "num.toString()   = " << num.toString() << endl;
    cout << "num.toString(4)  = " << num.toString(4) << endl;
    cout << "num.toInt        = " << num.toInt() << endl;
    cout << "num.toLong       = " << num.toLong() << endl;
    cout << "num.toLongLong   = " << num.toLongLong() << endl;
    cout << "num.toFloat      = " << num.toFloat() << endl;
    cout << "num.toDouble     = " << num.toDouble() << endl;
    cout << "num.toLongDouble = " << num.toLongDouble() << endl;
}

int main()
{
    WFloat num{0}, num1{0}, num2{0};
    int op{1};

    while (true)
    {
        cout << "input num = ";
        cin >> num;
        TypeConversion(num);

        cout << "\n\n";

        cout << "input num1 = ";
        cin >> num1;

        cout << "\ninput num2 = ";
        cin >> num2;

        cout << "\nselect operation:\n"
                "1) +\n"
                "2) -\n"
                "3) *\n"
                "4) /\n\n";
        cin >> op;
        cout << "\nresult = ";
        switch (op)
        {
        case 1:
            cout << num1 + num2 << endl;
            break;
        case 2:
            cout << num1 - num2 << endl;
            break;
        case 3:
            cout << num1 * num2 << endl;
            break;
        case 4:
            cout << num1 / num2 << endl;
            break;

        default:
            return -1;
        }

        cout << "\n\n";
        average();
        cout << "\n\n";
    }

    return 0;
}
